import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default({
    state: {
        menuList:[],
        permissions: [
        ],
        hasRouter:false,
        editableTabsValue: 'Index',//下标
        editableTabs: [{
            name: '首页',//标题
            index:'Index',
        }],
    },
    mutations: {
        clearState:(state)=>{
            state.token=''
            state.menuList=[]
            state.permissions=[]
            state.hasRouter=false
            state.editableTabs=[{
                name: '首页',
                index: 'Index',
            }]
            state.editableTabsValuen='Index'
        },
        setMenuList:(state,menu)=>{
            state.menuList=menu
        },
        setPermissions:(state,auth)=>{
           state.permissions=auth
        },
        changeRouterStatus:(state,hasRouter)=>{
            state.hasRouter=hasRouter
        },
        addTab:(state,menutabs)=> {
            let b=state.editableTabs.findIndex(e=>
                // e.index===menutabs.id.toString()
                e.index===menutabs.component
            )
            if(b==-1) {
                state.editableTabs.push({
                    name:menutabs.name,
                    index:menutabs.component
                });
            }
            state.editableTabsValue=menutabs.component
        },
    },
    actions: {
    },
    modules: {
    }
})